
import  axios from 'axios'
const ROOT_URL = 'https://api.imgur.com';
const token='95b67311b642095ec779761310e8a5aa4c3f69a7'

let fetchImages=function() {
    return axios.get(`${ROOT_URL}/3/account/me/images`, {
        headers: { Authorization: `Bearer ${token}`}
    });
}
let uploadImages=function (images) {
    const promises = Array.from(images).map(image => {
        const form = new FormData();
        form.append('image', image);

        return axios.post(`${ROOT_URL}/3/image`, form, {
            headers: {Authorization: `Bearer ${token}`}
        });
    });

    return Promise.all(promises);

}
export {fetchImages,uploadImages}
